clear all
set more off
capture log close
pause on

* This .do file starts with the file attachment sent on July 12 2021.  SC altered the top row manually to create some variable names in the .csv

/* SC */ cd "/Users/robertchaudoin/Dropbox/Complementarity ZC/Survey_PHL/PHL data/"
/* KZ */ capture use "/Users/kelebogilezvobgo/Dropbox/Complementarity/", clear

import delimited using "21012502 Havard PH 12072021 All varnames.csv", clear

capture rename ïstatus status
drop if status != "Complete"

* QQQ is an internal marker for practice runs of the survey; not an actual respondent if their ID contains "QQQ"
drop if strpos(sguidrmsid, "QQQ")

*** Treatment indicator
gen treatment = 0
replace treatment = 1 if strpos(recap, "can only")

*** Outcome measures variable construction
* The "_nn" versions stand for "no neither agree/disagree answers."  Those respondents are coded as missing for this version.

* Support for an ICC investigation
gen iccsupport_bin = 0
replace iccsupport_bin = 1 if iccinvsupport == "Somewhat agree" | iccinvsupport == "Strongly agree"

gen iccsupport_bin_nn = 0
replace iccsupport_bin_nn = 1 if iccinvsupport == "Somewhat agree" | iccinvsupport == "Strongly agree"
replace iccsupport_bin_nn = . if iccinvsupport == "Neither agree nor disagree"

gen iccsupport_num = .
replace iccsupport_num = 0 if iccinvsupport == "Strongly disagree"
replace iccsupport_num = 1 if iccinvsupport == "Somewhat disagree"
replace iccsupport_num = 2 if iccinvsupport == "Neither agree nor disagree"
replace iccsupport_num = 3 if iccinvsupport == "Somewhat agree"
replace iccsupport_num = 4 if iccinvsupport == "Strongly agree"


* Support for a domestic investigation
gen phlsupport_bin = 0
replace phlsupport_bin = 1 if countryinvsupport == "Somewhat agree" | countryinvsupport == "Strongly agree"

gen phlsupport_bin_nn = 0
replace phlsupport_bin_nn = 1 if countryinvsupport == "Somewhat agree" | countryinvsupport == "Strongly agree"
replace phlsupport_bin_nn = . if countryinvsupport == "Neither agree nor disagree"

gen phlsupport_num = .
replace phlsupport_num = 0 if countryinvsupport == "Strongly disagree"
replace phlsupport_num = 1 if countryinvsupport == "Somewhat disagree"
replace phlsupport_num = 2 if countryinvsupport == "Neither agree nor disagree"
replace phlsupport_num = 3 if countryinvsupport == "Somewhat agree"
replace phlsupport_num = 4 if countryinvsupport == "Strongly agree"



* ICC bias
gen iccbiased_bin = 0
replace iccbiased_bin = 1 if iccbiased == "Somewhat agree" | iccbiased == "Strongly agree"

gen iccbiased_bin_nn = 0
replace iccbiased_bin_nn = 1 if iccbiased == "Somewhat agree" | iccbiased == "Strongly agree"
replace iccbiased_bin_nn = . if iccbiased == "Neither agree nor disagree"

gen iccbiased_num = .
replace iccbiased_num = 0 if iccbiased == "Strongly disagree"
replace iccbiased_num = 1 if iccbiased == "Somewhat disagree"
replace iccbiased_num = 2 if iccbiased == "Neither agree nor disagree"
replace iccbiased_num = 3 if iccbiased == "Somewhat agree"
replace iccbiased_num = 4 if iccbiased == "Strongly agree"




* Support for the WOD
gen supportwod_bin = 0
replace supportwod_bin = 1 if supportwod == "Support" | supportwod == "Truly support"

gen supportwod_bin_nn = 0
replace supportwod_bin_nn = 1 if supportwod == "Support" | supportwod == "Truly support"
replace supportwod_bin_nn = . if supportwod == "May support and may not support"

gen supportwod_num = .
replace supportwod_num = 0 if supportwod == "Truly do not support"
replace supportwod_num = 1 if supportwod == "Do not support"
replace supportwod_num = 2 if supportwod == "May support and may not support"
replace supportwod_num = 3 if supportwod == "Support"
replace supportwod_num = 4 if supportwod == "Truly support"




* Support for rejoining the ICC
gen rejoinicc_bin = 0
replace rejoinicc_bin = 1 if rejoinicc == "Somewhat agree" | rejoinicc == "Strongly agree"

gen rejoinicc_bin_nn = 0
replace rejoinicc_bin_nn = 1 if rejoinicc == "Somewhat agree" | rejoinicc == "Strongly agree"
replace rejoinicc_bin_nn = . if rejoinicc == "Neither agree nor disagree"

gen rejoinicc_num = .
replace rejoinicc_num = 0 if rejoinicc == "Strongly disagree"
replace rejoinicc_num = 1 if rejoinicc == "Somewhat disagree"
replace rejoinicc_num = 2 if rejoinicc == "Neither agree nor disagree"
replace rejoinicc_num = 3 if rejoinicc == "Somewhat agree"
replace rejoinicc_num = 4 if rejoinicc == "Strongly agree"



* Satisfied with Duterte
gen dutertesat_bin = 0
replace dutertesat_bin = 1 if supportduterte == "Somewhat satisfied" | supportduterte == "Strongly satisfied"

gen dutertesat_bin_nn = 0
replace dutertesat_bin_nn = 1 if supportduterte == "Somewhat satisfied" | supportduterte == "Strongly satisfied"
replace dutertesat_bin_nn = . if supportduterte == "Neither satisfied nor dissatisfied"

gen dutertesat_num = .
replace dutertesat_num = 0 if supportduterte == "Strongly dissatisfied"
replace dutertesat_num = 1 if supportduterte == "Somewhat dissatisfied"
replace dutertesat_num = 2 if supportduterte == "Neither satisfied nor dissatisfied"
replace dutertesat_num = 3 if supportduterte == "Somewhat satisfied"
replace dutertesat_num = 4 if supportduterte == "Strongly satisfied"

*** Legal system
gen legsyscapable_bin = 0
replace legsyscapable_bin = 1 if legalsystem == "Somewhat agree" | legalsystem == "Strongly agree"

gen legsyscapable_bin_nn = 0
replace legsyscapable_bin_nn = 1 if legalsystem == "Somewhat agree" | legalsystem == "Strongly agree"
replace legsyscapable_bin_nn = . if legalsystem == "Neither agree nor disagree"

*** Standardized measures
 foreach dv in iccsupport_num iccbiased_num supportwod_num dutertesat_num {
	egen z2`dv' = std(`dv')
	}
*


***
* Respondent characteristics setup
***

*** Female
gen female = 0
replace female = 1 if gender == "Female"

*** Ethnicity
* Making indicators for the two largest in the sample
gen cebuano = 0
replace cebuano = 1 if ethnicity1 == "Cebuano"

gen tagalog = 0
replace tagalog = 1 if ethnicity1 == "Tagalog" | ethnicity2 == "tagalog"
*	One person manually entered tagalog

*** Religion
* Making a Catholic indicator
gen catholic = 0
replace catholic = 1 if religion1 == "Catholic"

*** Language
* There were only 310 that chose to take the survey in Tagalog
gen language_tagalog = 0
replace language_tagalog = 1 if language == "Tagalog"

*** Education
* . table education, stubwidth(40)
* I am post-secondary graduated (e g , voc |      1,462	* I am post-secondary graduated (e g , vocational certuficate, Bachelors degree, Masters degree, Doctorate)
* I attendend post-secondary school but I  |        300
*               I have no formal education |         21
*          I only completed primary school |          7
*        I only completed secondary school |        243
gen education_postsec = 0
replace education_postsec = 1 if  strpos(education, "I am")

*** Income
* Constructed indicators for 0-25th percentiles, 26-75, and 76+
gen income_lower25th = 0
gen income_26thto75th = 0
gen income_above75th = 0

replace income_lower25th = 1 if income <= 16000
replace income_26thto75th = 1 if income > 16000 & income <= 50000
replace income_above75th = 1 if income > 50000

*** Newshours
* Median is 4
gen newshours_morethan4 = 0
replace newshours_morethan4 = 1 if newshours > 4

*** Party
gen pdpl = 0
replace pdpl = 1 if party1 == "PDP-Laban"

gen rightparty = 0
replace rightparty = 1 if party1 == "PDP-Laban" | party1 == "Lakas" | party1 == "NPC" | party1 == "NUP" | party1 == "Nacionalista" 

*** Marital status
gen married = 0
replace married = 1 if marital == "Married"

*** Region
* There are 17 regions coded; this is just an indicator for Metro Manila/NCR
gen metromanilancr = 0
replace metromanilancr = 1 if strpos(region, "Manila")

***
* Other variables
***

*** Manipulation check variable construction
* Substrings from correct answers: "That country already"... // "The ICC cannot"...
gen manip1_correct = 0
replace manip1_correct = 1 if strpos(manipcheck1, "That country already")

gen manip2_correct = 0
replace manip2_correct = 1 if strpos(manipcheck2, "The ICC cannot")

gen manip_sum = manip1_correct + manip2_correct

* OLD VER gen noncomplier = 0
* OLD VER replace noncomplier = 1 if treatment == 1 & manip_sum == 0

gen complier1 = 0
gen complier2 = 0
gen complier1and2 = 0

replace complier1 = 1 if treatment == 1 & manip1_correct == 1
replace complier1 = 1 if treatment == 0

replace complier2 = 1 if treatment == 1 & manip2_correct == 1
replace complier2 = 1 if treatment == 0

replace complier1and2 = 1 if treatment == 1 & manip1_correct == 1 & manip2_correct == 1
replace complier1and2 = 1 if treatment == 0
	* In the USA survey, I labelled these "cchec" for "comprehension check."





* ICC investigation announced on Monday June 14
split end, parse(" ") generate(end_)
gen post_announcement = 0
replace post_announcement = 1 if end_1 == "14.06.2021" | end_1 == "15.06.2021"

* Time spent on the survey
*	Example start time: "03.06.2021 07:05:01"
gen double start_time = clock(start, "DMYhms")
gen double end_time = clock(end, "DMYhms")
gen timespent_manual = (end_time - start_time)/1000
	* This is the time spent on the survey measured in seconds


export delimited using "PHL_processed_2021_07_12.csv", replace
 

 
 
 

 
***
* Descriptive stats
***

global ctrls female age education_postsec income_lower25th income_26thto75th income_above75th cebuano tagalog catholic pdpl newshours_morethan4 metromanilancr
global dvs iccsupport_bin phlsupport_bin iccbiased_bin rejoinicc_bin supportwod_bin

estpost su treatment $dvs $ctrls
	est store full
estpost su treatment $dvs $ctrls if treatment == 1
	est store compl
estpost su treatment $dvs $ctrls if treatment == 0
	est store ctrl

*	Making summary stats table, means only, full - treatment only - control only
	esttab full compl ctrl ///
		using "/Users/robertchaudoin/Dropbox/Complementarity ZC/Survey_PHL/meanstats_tmtctrl_labelled_phl.tex", replace ///
		cells(mean(fmt(2))) nodep nonum  ///
		mtitle("Full" "Treatment" "Control") ///
		coeflabels(treatment "Compl. Treatment" ///
		iccsupport_bin "Support ICC Inv." phlsupport_bin "Support PHL Inv." iccbiased_bin "ICC is biased" rejoinicc_bin "Support Rejoin ICC" supportwod_bin "Approve War on Drugs" ///
		female "Female" age "Age" education_postsec "Post-Sec. Educ." income_lower25th "Income < 25th percentile" income_26thto75th "Income 26-75th percentile" income_above75th "Income > 75th percentile" cebuano "Cebuano" tagalog "Tagalog" catholic "Catholic" pdpl "PDP-Laban" newshours_morethan4 "News hours per week (>4)" metromanilancr "Metro Manila NCR")

 
 
 
 
 
 
 
 
 
 
 
 
*****************************
* PARTY SPLITS CHECKS
*****************************
bysort party1: su iccsupport_bin
bysort party1: su iccbiased_num
bysort party1: su supportwod_num
bysort party1: su dutertesat_num

bysort rightparty: su iccsupport_bin
bysort rightparty: su iccbiased_num
bysort rightparty: su supportwod_num
bysort rightparty: su dutertesat_num

* Party splits histograms
foreach psplit in pdpl rightparty {

twoway (histogram iccsupport_num if `psplit' == 1, ysc(r(0(0.1)1)) discr frac lcolor(gray) fcolor(gray)) ///
	(histogram iccsupport_num if `psplit' == 0, discr frac fcolor(none) lcolor(black)), legend(order(1 "PDP-L" 2 "Other")) ///
	xtitle("Support ICC Inv. (`psplit')") ylab(, nogrid) bgcolor(white) graphregion(color(white))
		graph export "/Users/robertchaudoin/Dropbox/Kill_Scrapes/IO Reviews/Survey/Figures from ZC study/psplit_`psplit'_iccsupp1.pdf", as(pdf) replace
		
twoway (histogram iccbiased_num if `psplit' == 1, ysc(r(0(0.1)1)) discr frac lcolor(gray) fcolor(gray)) ///
	(histogram iccbiased_num if `psplit' == 0, discr frac fcolor(none) lcolor(black)), legend(order(1 "PDP-L" 2 "Other")) ///
	xtitle("ICC Biased (`psplit')") ylab(, nogrid) bgcolor(white) graphregion(color(white))
		graph export "/Users/robertchaudoin/Dropbox/Kill_Scrapes/IO Reviews/Survey/Figures from ZC study/psplit_`psplit'_iccbias1.pdf", as(pdf) replace

twoway (histogram supportwod_num if `psplit' == 1, ysc(r(0(0.1)1)) discr frac lcolor(gray) fcolor(gray)) ///
	(histogram supportwod_num if `psplit' == 0, discr frac fcolor(none) lcolor(black)), legend(order(1 "PDP-L" 2 "Other")) ///
	xtitle("Support WOD (`psplit')") ylab(, nogrid) bgcolor(white) graphregion(color(white))
		graph export "/Users/robertchaudoin/Dropbox/Kill_Scrapes/IO Reviews/Survey/Figures from ZC study/psplit_`psplit'_wodsupp1.pdf", as(pdf) replace
 
twoway (histogram dutertesat_num if `psplit' == 1, ysc(r(0(0.1)1)) discr frac lcolor(gray) fcolor(gray)) ///
	(histogram dutertesat_num if `psplit' == 0, discr frac fcolor(none) lcolor(black)), legend(order(1 "PDP-L" 2 "Other")) ///
	xtitle("Satisfied w/ Duterte (`psplit')") ylab(, nogrid) bgcolor(white) graphregion(color(white))
		graph export "/Users/robertchaudoin/Dropbox/Kill_Scrapes/IO Reviews/Survey/Figures from ZC study/psplit_`psplit'_dutsupp1.pdf", as(pdf) replace
	}
 *
 
 * Party splits, standardized regressions
xxx 
***************************************************************************************
*ANALYSIS
***************************************************************************************

global controls "cebuano tagalog catholic age female income_lower25th income_26thto75th income_above75th education_postsec newshours_morethan4"

***
* Outcome measures
***

foreach dv in iccsupport phlsupport iccbiased supportwod rejoinicc dutertesat legsyscapable {
		qui reg `dv'_bin treatment
		su `dv'_bin if e(sample)
		di ".............................."
	}
*

* Histogram, support for ICC investigations by treatment
twoway (histogram iccsupport_num if treatment == 0, discr frac lcolor(gray) fcolor(gray) xlabel(0 "Strongly disagree" 1 "Somewhat disagree" 2 "Neither agr/disagr" 3 "Somewhat agree" 4 "Strongly agree", labs(vsmall) angle(-45))) ///
	(histogram iccsupport_num if treatment == 1, discr frac fcolor(none) lcolor(black)), legend(order(1 "Control" 2 "Treatment")) ///
	xtitle("Support ICC Inv. (PHL)") ylab(, nogrid) bgcolor(white) graphregion(color(white))
		graph export "/Users/robertchaudoin/Dropbox/Complementarity ZC/Survey_PHL/PHL data/hist_iccinv_bytmt_phl.eps", as(eps) preview(off) replace
		*graph export "PATH/hist_iccinv_bytmt_phl.eps", as(eps) preview(off) replace

* PDP-Laban tests		
twoway (histogram iccsupport_num if treatment == 0 & party1 == "PDP-Laban", discr frac lcolor(gray) fcolor(gray) xlabel(0 "Strongly disagree" 1 "Somewhat disagree" 2 "Neither agr/disagr" 3 "Somewhat agree" 4 "Strongly agree", labs(vsmall) angle(-45))) ///
	(histogram iccsupport_num if treatment == 1 & party1 == "PDP-Laban", discr frac fcolor(none) lcolor(black)), legend(order(1 "Control" 2 "Treatment")) ///
	xtitle("Support ICC Inv. (PHL, PDP-L only)") ylab(, nogrid) bgcolor(white) graphregion(color(white))
		graph export "/Users/robertchaudoin/Dropbox/Complementarity ZC/Survey_PHL/PHL data/hist_iccinv_bytmt_phl_pdp.eps", as(eps) preview(off) replace

foreach dv in iccsupport phlsupport iccbiased {
		di "..............  `dv'  ................"
	reg `dv'_bin treatment if party1 == "PDP-Laban"
	reg `dv'_bin treatment if party1 != "PDP-Laban"
	reg `dv'_num treatment if party1 == "PDP-Laban"
	reg `dv'_num treatment if party1 != "PDP-Laban"
		di ".............................."		
	}
*
	reg dutertesat_bin pdpl


foreach dv in iccsupport phlsupport iccbiased supportwod rejoinicc dutertesat legsyscapable {
		reg `dv'_bin treatment
		di ".............................."
	}
*


foreach dv in iccsupport phlsupport iccbiased supportwod rejoinicc dutertesat legsyscapable {
		reg `dv'_bin treatment
		reg `dv'_bin treatment $controls
		reg `dv'_bin_nn treatment
		reg `dv'_bin_nn treatment $controls
		di ".............................."
	}
*

* Quick check with noncomplier constraint

foreach dv in iccsupport phlsupport iccbiased supportwod rejoinicc {
		reg `dv'_bin treatment if noncomplier == 0
		reg `dv'_bin_nn treatment if noncomplier == 0
		di ".............................."
	}
*



***
* Manipulation checks
***
bysort treatment: tab manip1_correct
bysort treatment: tab manip2_correct

forvalues i = 1(1)2 {
	reg manip`i'_correct treatment
	}
